//
//  ViewController.swift
//  ToBeBigFE
//
//  Created by mingo on 2020/2/3.
//  Copyright © 2020 com.example. All rights reserved.
//

import UIKit

class ViewController : WebViewController {
    
    override func getLoadUrl() -> String {
        return WebManager.shared.getWebUrl(id: "home", page: "index.html")
    }
    
    override func viewDidLoad() {
        project = "home"
        super.viewDidLoad()
        
        /**
        开启摇动感应
        */
        UIApplication.shared.applicationSupportsShakeToEdit = true
        becomeFirstResponder()
    }
    
    override func motionBegan(_ motion: UIEvent.EventSubtype, with event: UIEvent?) {
        // 识别到摇一摇
        if motion == .motionShake {
            showDevAction()
        }
    }
    
    private func showDevAction() {
        let actionSheet = UIAlertController(title: "摇一摇", message: nil, preferredStyle: .actionSheet)
        let cancel = UIAlertAction(title: "取消", style: .cancel)
        actionSheet.addAction(cancel)
        let webDev = UIAlertAction(title: "进入开发环境?", style: .default) { action in
            let navVC = UINavigationController(rootViewController: DevSettingsController())
            self.present(navVC, animated: true, completion: nil)
        }
        actionSheet.addAction(webDev)
        self.present(actionSheet, animated: true, completion: nil)
    }
    
}

